package tech.aistar.prj.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tech.aistar.prj.model.dto.VideoDTO;
import tech.aistar.prj.model.pojo.Video;

import java.util.List;

public interface VideoMapper {

    @Select("select * from jdbc_video")
    List<Video> findAll();


    List<Video> findByUsername(String username);

    /**
     *
     * @param username 发布者
     * @param score 评分大于等于的
     * @param likes 点赞数字大于等于的
     * @param title 标题模糊查询
     * @return
     */
    List<VideoDTO> getByUsernameOrScoreOrlikesOrTitle(
            @Param("username")String username,@Param("score")Double score,
            @Param("likes")Integer likes,@Param("title")String title);

    int userAddVideo(Video video);

    /**
     * 物理删除
     * @param id
     * @return
     */
    int delVideo(Integer id);

    /**
     * 发布视频
     * @param id
     * @return
     */
    int releaseVideo(Integer id);


    @Select("select * from jdbc_video where id=#{Vid}")
    Video findByUid(Integer Vid);


    @Update("update jdbc_video set title = #{title},video_url = #{videoUrl},likes = #{likes},score = #{score},status = #{status} where id = #{id}")
    int updateVideo(@Param("title") String title,@Param("videoUrl")String videoUrl,@Param("likes") Integer likes,
                    @Param("score") Double score,@Param("status") Integer status,@Param("id")Integer id);
    
}

